/////////////////////////////////////page_tradeDetails/////////////////
$(document).on("pageInit", "#page_tradeDetails", function(e, pageId, $page) {
    my.givetitle('交易明细');
	 var now=new Date();
                y=now.getFullYear();
                m=now.getMonth()+1;
                d=now.getDay()+4;
                m=m<10?"0"+m:m;
                d=d<10?"0"+d:d;
                var endtime = y+"-"+m+"-"+d;

                var endnow=new Date();
                yy=endnow.getFullYear();
                mm=endnow.getMonth();
                dd=endnow.getDay()+3;
                mm=mm<10?"0"+mm:mm;
                dd=dd<10?"0"+dd:dd;
                var starttime = yy+"-"+mm+"-"+dd;
                $("#rang-time-start").calendar({});
      			$("#rang-time-end").calendar({});
                $(".time_start").val(starttime);
                $(".time_end").val(endtime);

               var  key=my.get_key(my.getCookie('token'));
              /* var getUserAccountDetailList=my.getUserAccountDetailList(my.getCookie('id'),starttime,endtime,1,1000,key);
                 //console.log(getUserAccountDetailList);return;
                  var loading = false;
                 var RentalOrderType=1;
                  var pageNow=1;
                   if(getUserAccountDetailList!=''){
                 	$('.useraccout').empty();
                    for(i=0;i<getUserAccountDetailList.length;i++){
                        var list="<li style='ackground-color: #f3f3f3;margin-bottom: 0.2rem;padding: 0.3rem;text-align: center;'>" +
                                "<div><span>"+getUserAccountDetailList[i].account_remark+"</span><span>"+types(getUserAccountDetailList[i].account_type)+"</span><span>"+typescash(getUserAccountDetailList[i].account_type,getUserAccountDetailList[i].account_cash)+"</span><div class='clear'></div></div>" +
                        "<div><span style='display: block;width: 6rem;float: left'>"+substringDate(getUserAccountDetailList[i].account_date)+"</span><span></span><span style='display:block;float: right;margin-right:0.3rem;width:2.5rem'>"+getUserAccountDetailList[i].account_balancea+"</span><div class='clear'></div></div></li>";

                        $('.useraccout').append(list)
                    }
                    $('.infinite-scroll-preloader').hide();

                   }else{
                   	   setTimeout(function(){
                   		 $('.infinite-scroll-preloader').hide();
                         alert('此时间段没有交易明细.')
                     	},1000)

                   }*/




                //收入支出类型转换
                function types(t){
                    if(t==1){
                        return "支出";
                    }
                    if(t==2){
                        return "收入";
                    }
                }
                //钱正负转化
                function typescash(type,cash){
                    if(type==1){
                        return "-"+cash;
                    }
                    if(type==2){
                        return "+"+cash;
                    }
                }
                //日期截取
                function substringDate(str){
                   return str.substring(0,16);
                }
//////////////////////////////////////////查询日期结束//////////////////////////////////////////////////////////////////
  //
                //检索
                $(".searchAccount").click(function(){
                    $(".useraccout").empty();
                    var startdate = $(".time_start").val();
                    var enddate = $(".time_end").val();
                    if(startdate=='' || enddate==''){
                        $.alert('请输入开始或结束时间');
                        return false;
                    }
                    startdate = startdate+' 00:00:00';
                    enddate = enddate+' 23:59:59';
                    var key=my.get_key(my.getCookie('token'));
                    var getUserAccountDetailList=my.getUserAccountDetailList(my.getCookie('id'),startdate,enddate,1,1000,key);
                    //console.log(getUserAccountDetailList);return;
                   setTimeout(function(){

                    if(getUserAccountDetailList!=''){
                        for(i=0;i<getUserAccountDetailList.length;i++){
                            var list="<li style='ackground-color: #f3f3f3;margin-bottom: 0.2rem;padding: 0.3rem;text-align: center;'>" +
                                    "<div><span>"+getUserAccountDetailList[i].account_remark+"</span><span>"+types(getUserAccountDetailList[i].account_type)+"</span><span>"+typescash(getUserAccountDetailList[i].account_type,getUserAccountDetailList[i].account_cash)+"</span><div class='clear'></div></div>" +
                                    "<div><span style='display: block;width: 6rem;float: left'>"+substringDate(getUserAccountDetailList[i].account_date)+"</span><span></span><span style='display:block;float: right;margin-right:0.3rem;width:2.5rem'>"+getUserAccountDetailList[i].account_balancea+"</span><div class='clear'></div></div></li>";

                            $('.useraccout').append(list);
                        }
                        if(getUserAccountDetailList.length<10){
                            $.detachInfiniteScroll($('.infinite-scroll'));
                            $('.infinite-scroll-preloader').hide();
                            $('.infiniteOver').show();
                        }else{
                            $.attachInfiniteScroll($('.page-current'));
                            $('.infinite-scroll-preloader').show();
                            $('.infiniteOver').hide();
                        }
                    }else{
                        $.detachInfiniteScroll($('.infinite-scroll'));
                        $('.infinite-scroll-preloader').hide();
                        $('.infiniteOver').show();
                    }
                 },1000);
                });


                //下拉分页
                //无限加载
                /**
                 * $(document).on("infinite", ".infinite-scroll-UserAccout", function() {
                    // 如果正在加载，则退出
                    if (loading) return;
                    pageNow=Math.ceil($('.useraccout li').length/10+0.01);
                   //console.log('pageNow:'+pageNow);
                    loading = true;
                    setTimeout(function() {
                        loading = false;
                        var startdate = $(".time_start").val();
                        var enddate = $(".time_end").val();
                        startdate = startdate+' 00:00:00';
                        enddate = enddate+' 23:59:59';
                        var key=my.get_key(my.getCookie('token'));
                        var getUserAccountDetailList=my.getUserAccountDetailList(my.getCookie('id'),startdate,enddate,pageNow,10,key);
                        if(getUserAccountDetailList!=''){
                            if(pageNow==1){
                                $('.useraccout').empty();
                            }
                           //console.log('载入条数:'+getUserAccountDetailList.length);
                            for(i=0;i<getUserAccountDetailList.length;i++){
                                var list="<li style='ackground-color: #f3f3f3;margin-bottom: 0.2rem;padding: 0.3rem;text-align: center;'>" +
                                        "<div><span>"+getUserAccountDetailList[i].account_remark+"</span><span>"+types(getUserAccountDetailList[i].account_type)+"</span><span>"+typescash(getUserAccountDetailList[i].account_type,getUserAccountDetailList[i].account_cash)+"</span><div class='clear'></div></div>" +
                                        "<div><span style='display: block;width: 6rem;float: left'>"+substringDate(getUserAccountDetailList[i].account_date)+"</span><span></span><span style='display:block;float: right;margin-right:0.3rem;width:2.5rem'>"+getUserAccountDetailList[i].account_balancea+"</span><div class='clear'></div></div></li>";

                                $('.useraccout').append(list);
                            }
                            if(getUserAccountDetailList.length<10){
                                $.detachInfiniteScroll($('.infinite-scroll'));
                                $('.infinite-scroll-preloader').hide();
                                $('.infiniteOver').show();
                            }
                        }else{
                            $.detachInfiniteScroll($('.infinite-scroll'));
                            $('.infinite-scroll-preloader').hide();
                            $('.infiniteOver').show();
                        }
                    }, 1000);
                });

                *
                * */
                //无限加载结束
});